{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "6a9a4d39",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "tf.executing_eagerly()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "8e3cdc29",
   "metadata": {},
   "outputs": [],
   "source": [
    "x=[[2,]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "5b656917",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Metal device set to: Apple M1\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2021-10-09 19:22:53.485251: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:305] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.\n",
      "2021-10-09 19:22:53.486045: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:271] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: <undefined>)\n"
     ]
    }
   ],
   "source": [
    "m=tf.matmul(x,x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "dd8adb09",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "tf.Tensor([[4]], shape=(1, 1), dtype=int32)\n"
     ]
    }
   ],
   "source": [
    "print(m)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "8e4f9b44",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[4]], dtype=int32)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "m.numpy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "8bd7da5b",
   "metadata": {},
   "outputs": [],
   "source": [
    "a=tf.constant([[1,2],\n",
    "              [3,4]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "a62da79c",
   "metadata": {},
   "outputs": [],
   "source": [
    "b=tf.add(a,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "d9a39456",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<tf.Tensor: shape=(2, 2), dtype=int32, numpy=\n",
       "array([[2, 3],\n",
       "       [4, 5]], dtype=int32)>"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "2f6e4071",
   "metadata": {},
   "outputs": [],
   "source": [
    "c=tf.multiply(a,b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "491fed9f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<tf.Tensor: shape=(2, 2), dtype=int32, numpy=\n",
       "array([[ 2,  6],\n",
       "       [12, 20]], dtype=int32)>"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "10d61ce8",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "d=np.array([[1,3],[4,9]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "8acbb406",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<tf.Tensor: shape=(2, 2), dtype=int32, numpy=\n",
       "array([[ 3,  9],\n",
       "       [16, 29]], dtype=int32)>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c+d"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "9f16f980",
   "metadata": {},
   "outputs": [],
   "source": [
    "g=tf.convert_to_tensor(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "36d4b2cb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<tf.Tensor: shape=(), dtype=int32, numpy=10>"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "g"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "c32d7259",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10.0"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "float(g)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8b720da4",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
